/*
 * Created by IntelliJ IDEA.
 * User: amrk
 * Date: 24/01/2004
 * Time: 15:20:30
 */
package com.talios.jira.feeds;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.talios.jira.browser.signals.JiraServerDetails;
import com.talios.jira.idea.JiraConfigurationComponent;

import java.util.List;

public class MyIssuesFeedBuilder extends ProjectFeedBuilder {
    private static final Logger LOGGER = Logger.getInstance("Jira Browser");

    public MyIssuesFeedBuilder(Project project) {
        JiraConfigurationComponent config = project.getComponent(JiraConfigurationComponent.class);
        List serverList = config.getConfiguration().getServerList();
        if (serverList != null && !serverList.isEmpty()) {
            setServers((JiraServerDetails[]) serverList.toArray(new JiraServerDetails[]{}));
        }
    }

    public MyIssuesFeedBuilder(JiraServerDetails[] servers) {
        setServers(servers);
    }

    /**
     * @jira INTPLUG-4 Support for Multiple Projects
     */
    public String buildRssFeedUrl(boolean includeUserDetails) {

        StringBuffer buf = getBaseBuffer(includeUserDetails);

        buf.append("&assignee=");
        buf.append(projectDetails.getServer().getUsername());
        buf.append("&assigneeSelect=specificuser&resolution=-1");

        buf.append("&summary=true");

        String rssFeed = buf.toString();
        return rssFeed;
    }

    public String getSearchFor() {
        return "Assigned";
    }

}